package com.httpsender;

import java.io.IOException;
import java.util.zip.DataFormatException;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;



public final class GameManagement{
	
	/*
	 * handle new high score
	 */
	public static void new_highScore(HighScore new_HighScore){
		/*
		boolean newHighScore = false;
		
		try{
			//LocalContent.set_NewHS(new_HighScore);
			newHighScore = true;
		}catch (Exception e){
			return;
		}
		OnlineContent.set_HighScore(new_HighScore);
		*/
	}
	
	/*
	 * returns the top 10 local high scores for level
	 */
	public static HighScore[] get_myHighScores(){
		HighScore[] myHighScores = new HighScore[10];
		/* try{
		 * myHighScores = LocalManagement.getHighScores();
		 * }catch (Exception e){
		 *  // error - no Highscores for level
		 * }
		 */		
		
		for (int i = 0; i < myHighScores.length; i++){
			myHighScores[i] = new HighScore();
		}	
		return myHighScores;
	}
	


	/*
	 * returns the top 10 high scores globally for the level
	 * @throws DataFormatException if content not found or returned incorrectly
	 */
	public static HighScore[] download_HighScores(MBLevel mbLevel) throws DataFormatException{
		
		HighScore[] retval = null;
		/*	
		try{
			retval = OnlineContent.get_HighScores(mbLevel);
		
		}catch(Exception e){
			return null;
		}
		if(retval == null){
			throw new DataFormatException();
		}
		*/
		return retval;
	}
	
	
	/*
	 * returns a level object from the server based on lvl unique key
	 */
	public static Level download_Level(String lvlName, String userName){
		Level downloaded_level = null;
		/*
		try{
			downloaded_level = OnlineContent.download_level(lvlName, userName);
			
		}catch(Exception e){
			
		}
		*/ 
		return downloaded_level;
	}
	
	/*
	 * submits a user created level to the Server
	 */
	public static void upload_Level(MBLevel submitLevel){
		/*
		  try { 
		     OnlineManagement.upload_lvl(submitLevel);
		  }catch(Exception e){

		  }   
		 */
		return 0; //success
	}
	
	//currently undefined
	/*
	 * returns 10 level segments based on a user query
	 * this should be used when displaying previews of levels for to download
	 */
	public static Level[] queryLevels(String query){
		Level[] lvlChoices =  new Level[10];
		//OnlineManagement.getLevels(query);
		for (int i = 0; i < lvlChoices.length; i++){
			lvlChoices[i] = new Level();
		}	
		return lvlChoices;
		
	}
	
}